#include <cstdio>
#include <queue>
using namespace std;

const long long mod = 1000000007;

struct node
{
    long long x, step;
};

// 设f(x)=4x+3，g(x)=8x+7，h(x)=2x+1
// 有：
// 1、f(g(x)) = g(f(x))
// 2、f(x) = h(h(x))
// 3、g(x) = h(h(h(x)))
// 所以我们可以用h(x)来进行计算，减少分支，去重的开销

int hungry(int x)
{
    queue<node> Q;
    Q.push({x, 0});
    int res = -1;
    while (!Q.empty())
    {
        node curr = Q.front();
        Q.pop();
        if (curr.x % mod == 0 && res != 1)
            break;

        if (curr.step > 300000) // 2x+1
            break;

        long long x = (curr.x << 1) + 1;
        Q.push({x, curr.step + 1});
    }
    return (res + 2) / 3;
}

int main()
{
    long long x;
    while (scanf("%lld", &x) != EOF)
    {
        if (x >= 1 && x <= 1000000006)
            printf("%d\n", hungry(x));
    }
    return 0;
}